package com.example.onlinemusic.test;

import com.example.onlinemusic.common.common;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;

public class LovePage extends common {
    public static String url = "http://127.0.0.1:8080/loveMusic.html";

    //3自动在输入框帮我输入账号密码
    public LovePage() {
        super(url);
    }
    //测试查询功能(成功)
    public void searchSuccess(String s){
        driver.findElement(By.xpath("//*[@id=\"exampleInputName2\"]")).sendKeys(s);
        driver.findElement(By.xpath("//*[@id=\"submit1\"]")).click();
    }

    //测试查询功能失败（没有歌）
    public void searchFail(){
        driver.findElement(By.xpath("//*[@id=\"exampleInputName2\"]")).sendKeys("c");
        driver.findElement(By.xpath("//*[@id=\"submit1\"]")).click();
    }

    public void operation(int i) throws InterruptedException {
        driver.findElement(By.xpath("//*[@id=\"info\"]/tr["+i+"]/td[4]/button")).click();
        Thread.sleep(500);
        Alert alert=driver.switchTo().alert();
        alert.accept();
    }
}
